<?php 

namespace pmvc\mvc\security\basic;

use pmvc\mvc\security\User;
use pmvc\log\Log;

use stdClass;

class BasicUser
	extends stdClass
	implements User {

	public $roles;
	public $id;
	public $username;
	public $password;
	public $isPasswordEncoded;

	public function __construct(Array $roles, $id,  $username, $password, $isPasswordEncoded, $data=Array()) {
    	$this->roles 				= $roles;
    	$this->id					= $id;
    	$this->username				= $username;
    	$this->password				= $password;
    	$this->isPasswordEncoded	= $isPasswordEncoded;
    	foreach ($data as $key => $value) {
    		if (!isset($this->$key)) {
    			$this->$key = $value;
    		} else {
    			Log::warn("Key {0} exists on user object, skipping", $key);
    		}
    	}
    }

	public function getRoles() {
		return $this->roles;
	}

	public function getId() {
		return $this->id;
	}

	public function getUsername() {
		return $this->username;
	}
	
	public function getPassword() {
		return $this->password;
	}
	
	public function isPasswordEncoded() {
		return $this->isPasswordEncoded;
	}
	
}

?>